﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Reborn_WorldServer;

namespace App1AppHandler
{
    public class Creature_HealSacrifice : Creature
    {
        public Creature_HealSacrifice(AppHandler2 gameHandler) : base(gameHandler) { }

        //This method is always called from within a lock and tile will be updated by caller.
        public override void SetPosition(MapItem mapItem)
        {
            base.SetPosition(mapItem);

            if (petController != null)
            {
                CreatureBase masterCreature = petController.MasterCreature;
                if (currentMapItem == masterCreature.currentMapItem)
                {
                    masterCreature.HP = masterCreature.HP + 500;
                    if (masterCreature is Character)
                    {
                        Character c = (Character)masterCreature;
                        c.Update_Character();

                        c.SendMessage(Name + " heals you! (500)", "spelldefense");
                    }

                    petController.Dismiss();

                    List<Character> charactersWithinRange = currentMapItem.getCharactersWithin8();
                    foreach (Character c in charactersWithinRange)
                        c.AddAnimation("GreenGlow", currentMapItem.parentMap.MapID, currentMapItem.MapX, currentMapItem.MapY, 1);
                }
            }
        }

    }
}
